#!/usr/bin/env python


import beancount.ingest.extract
from beancount.ingest.importers import csv
from smart_importer import PredictPostings, apply_hooks
from smart_importer.detector import DuplicateDetector
import jieba

jieba.initialize()
def tokenizer(s): return list(jieba.cut(s))


beancount.ingest.extract.HEADER = ''

CONFIG = [
    # BOC Credit
    apply_hooks(csv.Importer(
        {
            csv.Col.DATE: '交易日期',
            csv.Col.NARRATION1: '对方账户名称',
            # csv.Col.NARRATION2: '附言',
            csv.Col.AMOUNT_DEBIT: '支出金额',
            csv.Col.AMOUNT_CREDIT: '收入金额',
            csv.Col.BALANCE: '余额'
        
        },
        account='Assets:Bank:BOC:Card0000',
        currency='CNY',
        regexps='网点名称',
        csv_dialect='excel-tab',
        encoding="UTF-16"
       # categorizer=guess.guess2]
    ), [DuplicateDetector(),PredictPostings(string_tokenizer=tokenizer)])
]
